#导入webdriver
import yaml
from selenium import webdriver
from selenium.webdriver.common.by import By

from time import sleep
#打开浏览器
# driver = webdriver.Firefox()
driver = webdriver.Chrome()
# driver.maximize_window()
# 获取当前打开的窗口的所有句柄
window = driver.window_handles
print("当前窗口：",driver.current_window_handle)
#打开网站
driver.get('https://edutony-staging.fooyo.shop/#/')
driver.implicitly_wait(5)

with open('/Users/liaowei/PycharmProjects/pythonProject/edutony_staging/data/data_signup.yml') as f:
    result = yaml.safe_load(f)
    [li] = result.get("user")
    ids = result.get("ids")


#注册用户

driver.find_element(By.XPATH, '//*[@id="app"]/div/header/div/div[2]/div[2]/a[2]').click()
driver.find_element(By.CSS_SELECTOR, '[placeholder="Enter your Username "]').send_keys(li[0])
driver.find_element(By.CSS_SELECTOR, '[placeholder="Enter your email"]').send_keys(li[1])
driver.find_element(By.CSS_SELECTOR, '[placeholder="Password"]').send_keys(li[2])
driver.find_element(By.CSS_SELECTOR, '[placeholder="Password (confirmation)"]').send_keys(li[3])
driver.find_element(By.CSS_SELECTOR, '[placeholder="Full name"]').send_keys(li[4])
driver.find_element(By.CSS_SELECTOR,'[placeholder="Secondary/JC"]').click()
driver.find_element(By.CSS_SELECTOR,f'.el-scrollbar__view.el-select-dropdown__list>li:nth-child({li[5]})').click()
driver.find_element(By.CSS_SELECTOR, '[placeholder="School"]').send_keys(li[6])
driver.find_element(By.CSS_SELECTOR,'[placeholder="Cuntry"]').click()
driver.find_element(By.XPATH,f'//*[text()="China"]').click()
# driver.find_element(By.CSS_SELECTOR, '#app > section > div.register-content > button > span').click()
# driver.quit()
